// Prerequisites.pch will be the pre-compiled header
#include "Prerequisites.h"

Color g_white(1.f, 1.f, 1.f, fOPAQUE);	
Color g_black(0.f, 0.f, 0.f, fOPAQUE);
Color g_cyan(0.f, 1.f, 1.f, fOPAQUE);	
Color g_red(1.f, 0.f, 0.f, fOPAQUE);
Color g_green(0.f, 1.f, 0.f, fOPAQUE);
Color g_blue(0.f, 0.f, 1.f, fOPAQUE);
Color g_yellow(1.f, 1.f, 0.f, fOPAQUE);	
Color g_gray40(0.4f, 0.4f, 0.4f, fOPAQUE);
Color g_gray25(0.25f, 0.25f, 0.25f, fOPAQUE);
Color g_gray65(0.65f, 0.65f, 0.65f, fOPAQUE);
Color g_transparent (1.f, 0.f, 1.f, fTRANSPARENT);

// Note! If you change these direction vectors around to suit yourself
// Make sure you change it so it retains a left handed
// coordinate system 
Vector3 g_right(1.f, 0.f, 0.f);
Vector3 g_up(0.f, 1.f, 0.f);
Vector3 g_forward(0.f, 0.f, 1.f);

Vector4 g_up4(g_up.x, g_up.y, g_up.z, 0.f);
Vector4 g_right4(g_right.x, g_right.y, g_right.z, 0.f);
Vector4 g_forward4(g_forward.x, g_forward.y, g_forward.z, 0.f);

const float fOPAQUE = 1.f;
const float fTRANSPARENT = 0.f;

const int MEGABYTE = 1024 * 1024;
const float SIXTY_HERTZ = 16.66f;

const int SCREEN_WIDTH = 800;
const int SCREEN_HEIGHT = 600;

//#define MEM_LOG
#if defined(_DEBUG) && defined(MEM_LOG)

void* operator new(size_t size, int memType, const char* filename, int lineNum)
{
	// We have to do this old-school since we're not allowed to dynamically allocate memory here.
	char buffer[2048];
	int index = 0;
	index += strlen(ultoa(size, buffer, 10));
	strcpy(buffer+index, " -> ");
	index += 4;
	strcpy(buffer+index, filename);
	index += strlen(filename);
	buffer[index] = ':';
	++index;
	index += strlen(itoa(lineNum, buffer+index, 10));
	buffer[index] = '\n';
	++index;
	buffer[index] = '\0';
	++index;
	OutputDebugStringA(buffer);

	return _malloc_dbg(size, memType, filename, lineNum);
}

void operator delete(void* pMemory)
{
	_free_dbg(pMemory, 1);
}

void* operator new[](size_t size, int memType, const char* filename, int lineNum)
{
	// We have to do this old-school since we're not allowed to dynamically allocate memory here.
	char buffer[2048];
	int index = 0;
	index += strlen(ultoa(size, buffer, 10));
	strcpy(buffer+index, " -> ");
	index += 4;
	strcpy(buffer+index, filename);
	index += strlen(filename);
	buffer[index] = ':';
	++index;
	index += strlen(itoa(lineNum, buffer+index, 10));
	buffer[index] = '\n';
	++index;
	buffer[index] = '\0';
	++index;
	OutputDebugStringA(buffer);

	return _malloc_dbg(size, 1, filename, lineNum);
}

void operator delete[](void* pMemory)
{
	_free_dbg(pMemory, 1);
}

#endif